<template>
  <IndexSwiper></IndexSwiper>
  <view class="index-page">
    <NavBar></NavBar>
    <view class="banner-box">
      <image class="banner" :src="itm.image" v-for="(itm, idx) in adList" :key="idx" @click="toDetail(itm)"></image>
    </view>
    <view class="index-tit">
      <!-- 根据需求隐藏 -->
      <!-- <Title title="购车优惠"></Title> -->
    </view>
    <Discounts></Discounts>
    <!-- <view class="index-tit">
      <Title title="实拍视频"></Title>
    </view>
    <Videos></Videos> -->
    <view class="index-tit">
      <Title title="推荐车源"></Title>
    </view>
    <CarSource ref="refCarSource"></CarSource>
  </view>
</template>

<script >
import { ref } from "vue"
import Title from "@/components/ui/title"
import IndexSwiper from "./com/indexSwiper"
import NavBar from "./com/navBar"
import Discounts from "./com/discounts"
import CarSource from "./com/carSource"
import Videos from "./com/videos"
import service from "@/path/service"
import { toDetail } from "./data"

export default {
  components: {
    Title,
    IndexSwiper,
    NavBar,
    Discounts,
    CarSource,
    Videos,
  },
  data() {
    return {

    }
  },
  setup() {
    const adList = ref([])
    service.get("api/ycg/home/banner", { pageType: 2 }).then(res => adList.value = res)


    return {
      toDetail,
      adList,
    }
  },
  onPullDownRefresh() {
    if (this.$refs.refCarSource?.initPagingQuery instanceof Function) {
      this.$refs.refCarSource.initPagingQuery().finally(() => {
        uni.stopPullDownRefresh();
      })
    }
  },
  onReachBottom() {
    if (this.$refs.refCarSource?.loadPagingMore instanceof Function) {
      this.$refs.refCarSource.loadPagingMore()
    }
  },
onShareAppMessage(res) {
      return {
        title: '',
        path: '/pages/tabbar/index/index',
      }
    },
    onShareTimeline() {
		return {
			title: '优车够小程序',
			path: '/pages/tabbar/index/index',
			imageUrl: '/static/logo2.png'
		};
  }
}
</script>

<style lang="less" scoped>
@import url(./index.less);
</style>
